<template>
    <div>
        <div class="container">
            <div class="handle-box">
                <el-select v-model="query.case_source" @change="handleSearch(query.case_number,query.tcs_note_id,query.case_source,query.case_type)" clearable placeholder="案件来源" class="handle-select mr10">
                    <el-option key="1" label="市场查获" value="市场查获"></el-option>
                    <el-option key="2" label="投诉举报" value="投诉举报"></el-option>
                    <el-option key="3" label="上级交办" value="上级交办"></el-option>
                </el-select>
                <el-select v-model="query.case_type" @change="handleSearch(query.case_number,query.tcs_note_id,query.case_source,query.case_type)" clearable placeholder="案件性质" class="handle-select mr10">
                    <el-option key="1" label="一般案件" value="一般案件"></el-option>
                    <el-option key="2" label="简易案件" value="简易案件"></el-option>
                </el-select>
                <el-input v-model="query.case_number" placeholder="立案编号" @change="handleSearch(query.case_number,query.tcs_note_id,query.case_source,query.case_type)" class="handle-input mr10"></el-input>
                <el-button type="primary" :icon="Search" @change="handleSearch(query.case_number,query.tcs_note_id,query.case_source,query.case_type)">搜索</el-button>
            </div>
            <el-table :data="tableList" border class="table" ref="multipleTable" header-cell-class-name="table-header">
                <!--        <el-table-column prop="case_id" label="案件号" width="100" align="center"></el-table-column>-->
                <el-table-column prop="case_source" label="案件来源" align="center"></el-table-column>
                <el-table-column prop="case_number" label="立案编号" width="180" align="center"></el-table-column>
                <el-table-column prop="case_update_time" label="更新时间"  align="center"></el-table-column>
                <el-table-column prop="case_type" label="案件性质" align="center"></el-table-column>
                <el-table-column prop="date_of_filing" label="立案日期"  align="center"></el-table-column>
                <el-table-column label="行政罚款收据状态" align="center" width="200">
                    <template #default="scope">
                        <div v-if="scope.row.tcs_note_id === '行政处罚决定书已完成' ">
                            <el-tag :type=" 'danger'">行政处罚决定书已完成</el-tag>
                        </div>
                        <div v-if="scope.row.tcs_note_id === '行政罚款收据上传完成' ">
                            <el-tag :type=" 'danger'">行政罚款收据上传完成</el-tag>
                        </div>


                        <div v-if="scope.row.tcs_note_id === '已完成' ||
                                scope.row.tcs_note_id ==='行政罚款收据已完成'||
                                scope.row.tcs_note_id ==='结案报告表已完成'">
                            <el-tag :type=" 'success'">已完成 </el-tag>
                        </div>
                    </template>
                </el-table-column>
                <el-table-column label="下一步操作" width="389px" align="center">
                    <template #default="scope">
                        <div v-if="scope.row.tcs_note_id === '行政处罚决定书已完成' ">
                            <el-button text :icon="Edit" class="blue" @click="administrative_fine_table(scope.row)" >
                                行政罚款收据上传
                            </el-button>

                        </div>
                        <div v-if="scope.row.tcs_note_id === '行政罚款收据上传完成' ">
                            <el-button text :icon="Edit" class="blue" @click="return_article_table(scope.row)" >
                                涉案物品返还清单填写
                            </el-button>
                        </div>

                        <div v-if="scope.row.tcs_note_id === '已完成' ||
                                scope.row.tcs_note_id ==='行政罚款收据已完成'||
                                scope.row.tcs_note_id ==='结案报告表已完成'">
                            <el-button text :icon="Edit" class="blue" @click="administrative_fine_browse(scope.row)" >
                                查看行政罚款收据
                            </el-button>
                            <el-button text :icon="Edit" class="blue" @click="return_item_browse(scope.row)">
                                查看涉案物品返还清单
                            </el-button>

                        </div>


                    </template>
                </el-table-column>
            </el-table>
          <div class="pagination">
            <el-pagination
                background
                layout="total, prev, pager, next"
                :current-page="query.pageIndex"
                :page-size="query.pageSize"
                :total="pageTotal"
                @current-change="handlePageChange"
            ></el-pagination>
          </div>
        </div>

        <!-- 行政罚款收据上传 -->
        <el-dialog title="行政罚款收据上传" v-model="Administrative_fine_Visible" width="30%">
            <el-form label-width="150px">
                <el-form-item label="填写时间">
                    <el-date-picker  v-model="img_form_data.time"  type="datetime" placeholder="选择上传日期" value-format="YYYY-MM-DD HH:mm:ss">
                    </el-date-picker>
                </el-form-item>

                <el-form-item label="点击上传罚款收据" >
                    <el-upload class="upload-demo"
                               action="#"
                               :limit=2
                               list-type="picture-card"
                               :on-change="handleChange"
                               :on-remove="handleRemove"
                               :on-preview="true"
                               :auto-upload="false"
                               :on-progress="true"
                               accept="bmp, jpg, png, gif, jpeg"
                               :show-file-list="true" >
                        <el-icon class="el-icon--upload"><upload-filled /></el-icon>
                    </el-upload>
                </el-form-item>
            </el-form>
            <template #footer>
				<span class="dialog-footer">
					<el-button @click="Administrative_fine_Visible = false">取 消</el-button>
					<el-button type="primary" @click="certern_administrative_fine">确 定</el-button>
				</span>
            </template>
        </el-dialog>




        <el-dialog title="涉案物品返还清单填写" v-model="Return_article_list_Visible" width="55%">
            <el-form ref="form"  :model="form" label-width="100px">
                <el-row>
                    <el-col :span="12">
                <el-form-item label="返还日期">
                    <el-date-picker v-model="return_article_data_storage.return_time"   type="datetime" placeholder="选择返还日期" value-format="YYYY-MM-DD HH:mm:ss">
                    </el-date-picker>
                </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="鉴别损耗费">
                            <el-input v-model="return_article_data_storage.identificate_loss" placeholder="单位(元)"></el-input>
                        </el-form-item>

                    </el-col>

                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="送达人">
                            <el-select v-model="return_article_data_storage.returnee1"  clearable filterable placeholder="请选择">
                                <el-option
                                        v-for="(item,index) in interrogator_Data"
                                        :key='index'
                                        :label='item.staff_name'
                                        :value='item.staff_id'
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="送达人">
                            <el-select v-model="return_article_data_storage.returnee2"   clearable filterable placeholder="请选择">
                                <el-option
                                        v-for="(item,index) in interrogator_Data"
                                        :key='index'
                                        :label='item.staff_name'
                                        :value='item.staff_id'
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="24">
                    <el-col :span="500">
                <el-form-item label="返还物品">
                    <el-select v-model="return_article_data_storage.evi_id" @change="get_return_item_clause_opinion(return_article_data_storage.evi_id)" clearable filterable placeholder="请选择">
                        <el-option
                                v-for="(item,index) in return_item_Data"
                                :key='index'
                                :label='item.return_item_name'
                                :value='item.evi_id'
                        ></el-option>
                    </el-select>
                </el-form-item>
                    </el-col>

                    <div  align="right">
                        <el-button type="primary"  @click="return_item_add">添加</el-button>
                    </div>

                </el-row>

            </el-form>
            <el-table :data="evidence_ciga_Data" border class="table" ref="multipleTable" header-cell-class-name="table-header">
                <el-table-column prop="ciga_variety" label="品种"   align="center"></el-table-column>
                <el-table-column prop="barcode" label="条形码"  align="center"></el-table-column>
                <el-table-column prop="ciga_model" label="规格型号"  align="center"></el-table-column>
                <el-table-column prop="inkjet" label="喷码"  align="center"></el-table-column>
                <el-table-column prop="evi_number" label="数量(条)" width="100" align="center"></el-table-column>
                <el-table-column label="操作"  align="center" >
                    <template #default="scope">
                        <el-button  text :icon="Delete" class="red" @click="returnDelete(scope.$index, scope.row)"  >
                            删除
                        </el-button>
                    </template>
                </el-table-column>
            </el-table>
            <template #footer>
              <span class="dialog-footer">
                  <el-button @click="Return_article_list_Visible = false">取 消</el-button>
        <el-button type="primary" @click="certain_case_return">确 定</el-button>
              </span>
            </template>
        </el-dialog>


        <!--    行政罚款收据视图-->
        <el-dialog title="" v-model="View_administrative_fine_Visible" width="34%">
            <html>
            <head>
                <title>行政罚款收据</title>
            </head>
            <body>
            <div v-for="item in  case_img_Data">
                <h1 align="center">
                    {{item.type}}
                </h1>
                <table border="1"  style="border-collapse: collapse;" width="100%" >
                    <tr >
                        <th width="100%"  align="center" height="500px">
                            <div class="table-td">
                            <el-image
                                    class="table-td-thumb"
                                    :src="item.img"
                                    :z-index="10"
                                    :preview-src-list="[item.img]"
                                    preview-teleported>
                            </el-image>
                            </div>
                        </th>
                    </tr>
                    <tr>
                        <th colspan="2" align="left">
                            说明事项：当事人{{administrative_fine_data_storage.tir_person}}因{{administrative_fine_data_storage.illegal_behavior}}被我局查处，我局于
                            {{administrative_fine_data_storage.year1}}年{{administrative_fine_data_storage.month1}}月{{administrative_fine_data_storage.day1}}日作出处以罚款计人民币{{administrative_fine_data_storage.administrative_fine_chinese}}
                            (￥{{administrative_fine_data_storage.administrative_fine}}元)的行政处罚，，该收据为当事人{{administrative_fine_data_storage.year2}}年{{administrative_fine_data_storage.month2}}月{{administrative_fine_data_storage.day2}}日缴纳罚款的回单。<br>
                        </th>
                    </tr>

                </table>
            </div>

            </body>
            </html>
        </el-dialog>

        <!--涉案物品返还清单-->
        <el-dialog title="" v-model="Return_item_Browse_Visible" width="42%">
            <html>
            <head>
                <title>涉案物品返还清单</title>
            </head>
            <body>
            <h1 align="center">
                福建省闽侯县烟草专卖局
            </h1>
            <h1 align="center">
                涉案物品返还清单
            </h1>
            <table border="1" style="border-collapse: collapse;" width="100%" >
                <tr>
                    <td align="center" width="20%" height="40px"><strong>品种</strong></td>
                    <td width="25%" align="center" height="30px"><strong>条形码</strong></td>
                    <td width="20%" align="center" height="30px"><strong>规格型号</strong></td>
                    <td width="20%" align="center" height="30px"><strong>数量(条)</strong></td>
                    <td width="15%" align="center" height="30px"><strong>备注</strong></td>
                </tr>
            </table>
            <div v-for="item in evidence_ciga_Data">
                <table border="1" style="border-collapse: collapse;" width="100%" >
                    <tr>
                        <td width="20%" align="center" height="30px"><strong >{{item.ciga_variety}}</strong></td>
                        <td width="25%" align="center" height="30px"><strong>{{item.barcode}}</strong></td>
                        <td width="20%" align="center" height="30px"><strong>{{item.ciga_model}}</strong></td>
                        <td width="20%" align="center" height="30px"><strong>{{item.evi_number}}</strong></td>
                        <td width="15%" align="center" height="30px">/</td>
                    </tr>
                </table>
            </div>

            <table border="1" style="border-collapse: collapse;" width="100%" height="40px">
                <tr>
                    <th align="center" width="20%" >
                        <span style="text-align: center">合计</span>
                    </th>
                    <th align="center" width="25%">
                        <span style="text-align: center">/</span>
                    </th>
                    <th align="center" width="20%">
                        <span style="text-align: center">/</span>
                    </th>
                    <th align="center" width="20%">
                        <span style="text-align: center">{{return_article_data_storage.ciga_number}}</span>
                    </th>
                    <th align="center" width="15%">
                        <span style="text-align: center">/</span>
                    </th>
                </tr>

            </table>
            <table border="1" style="border-collapse: collapse;" width="100%" height="40px">
                <tr>
                    <th align="left" width="25%" colspan="5" height="50px">
                        <span >&nbsp;&nbsp;&nbsp;&nbsp;鉴别检验样品损耗费合计<u>{{return_article_data_storage.identificate_loss}}</u>元（大写<u>{{return_article_data_storage.identificate_loss_chinese}}</u>）。</span>
                    </th>
                </tr>
            </table>
            <table border="1" style="border-collapse: collapse;" width="100%" >
                <tr>
                    <td align="left" width="50%" colspan="5" height="200px" valign="top">
                        <br>
                        <div><strong><font size="4">以上物品已收到。</font></strong></div>
                            <br><br>
                        <div><strong><font size="4">接收单位（印章）：</font></strong></div>
                        <br><br>
                        <div><strong><font size="4">接收人：</font></strong></div>
                        <br><br>
                        <div align="right"><strong><font size="4">&nbsp;&nbsp;年&nbsp;&nbsp;&nbsp;&nbsp;月&nbsp;&nbsp;&nbsp;&nbsp;日&nbsp;&nbsp;&nbsp;&nbsp;</font></strong></div>
                    </td>
                    <td align="left" width="50%" colspan="5" height="200px" valign="top">
                        <br>
                        <div><strong><font size="4">返还单位（印章）：</font></strong></div>
                        <br><br>
                        <div><strong><font size="4">返还人：</font></strong></div>
                        <br>
                        <div align="center"><strong><font size="4">执法证号：{{return_article_data_storage.staff_license_1}}</font></strong></div><br>
                        <div align="center"><strong><font size="4">执法证号：{{return_article_data_storage.staff_license_2}}</font></strong></div><br>

                        <div align="right"><strong><font size="4">&nbsp;&nbsp;年&nbsp;&nbsp;&nbsp;&nbsp;月&nbsp;&nbsp;&nbsp;&nbsp;日&nbsp;&nbsp;&nbsp;&nbsp;</font></strong></div>
                    </td>
                </tr>
            </table>
            </body>

            </html>
            <template #footer>
        <span class="dialog-footer">
            <el-button @click="Return_item_Browse_Visible=false" >取 消</el-button>
                <el-button type="primary" :icon="Printer"  @click="return_item_word" >
                打印
              </el-button>
        </span>
            </template>
        </el-dialog>


    </div>
</template>

<script setup lang="ts" name="basetable">
import { ref, reactive } from 'vue';
import { ElMessage, ElMessageBox } from 'element-plus';
import { Delete, Edit, Search, Plus,Printer } from '@element-plus/icons-vue';
import {
    case_evi_Create,
    case_evi_Views,
    case_legal_Create,
    ciga_evudence_Create,
    end_record_data,
    evi_Views,
    fetchData_case,
    fetchData_case_Create,
    fetchData_case_update,
    fetchData_legal_clause,
    fetchData_mer,
    fetchData_s_mongodb_evidence_Cre,
    fetchData_s_mongodb_evidence_Views,
    fetchData_tobacco,
    fetchData_user,
    illegal_record_data,
    illegal_record_Search,
    mer_Create,
    mer_search_api,
    review_price_data,
    staff_evidence_create,
    staff_evidence_data,
    end_record_show,
    record_inquiry_show,
    record_inquiry_print,
    case_evidence_Views,
    case_evidence_Edit,
    question_answer_clause_delete,
    price_review_clause_delete,
    fetchData_user_Edit,
    fetchData_price_Edit,
    hearing_arrive_document,
    fetchData_interrogator_clause,
    fetchData_inquiry_record_Confirm,
    fetchData_arrive_document_Confirm,
    hearing_notice_data,
    fetchData_hearing_notice_Confirm,
    hearing_notice_browse_data,
    penalty_advance_notice_data,
    fetchData_advance_notice_Confirm,
    advance_arrive_document,
    advance_penalty_data,
    arrive_document_print_data,
    fetchData_time_upload,
    fetchData_return_item_clause,
    return_item_Views,
    return_item_Create,
    return_item_clause_delete,
    fetchData_case_return_Confirm,
    administrative_fine_browse_data, inquiry_record_print_data, return_item_print_data
} from '../api/index';
import {
     export_word_19,
} from './table_inquiry.vue'

//案件表数据
interface TableItem {
    case_id:number,
    date_of_filing:string,
    date_of_closing:string,
    date_of_archive:string,
    case_source:string,
    case_number:string,
    archive_person:string,
    case_update_time:string,
    ase_type:string,
    case_remark:string,
    tcs_note_id:string,
    ciga_flag:string,
    ciga_num_flag:string,
    mer_flag:string,
}

//案件暂存数据
const create_case = reactive({
    case_id:0,
    staff_evi_id:0,
    staff_id:0,
    staff_evi_send_per:'',
    staff_evi_check_per1:'',
    staff_evi_check_per2:'',
    staff_evi_send_time:'',
    staff_evi_send_unit:'',
    staff_evi_send_result:'',
    staff_evi_rec_address:'',
    staff_evi_status:'',
    staff_evi_per_note:'',
    mer_flag:'',
    ciga_num_flag:'',
    ciga_flag:'',
    test:[],
    img_data:'',
    standard:'',
    tir_id:0,
    tlc_id:0,
    illegal_behavior:'',
    evi_id_number:'',
    evi_id:'',
    date_of_filing:'',
    date_of_closing:'',
    date_of_archive:'',
    case_source:'',
    case_number:'',
    archive_person:'',
    case_update_time:'',
    case_type:'',
    case_remark:'',
    mer_id:0,
    tcs_note:'',
    cs_note:'',
    tce_time:'',
    tce_number:0,
    tce_amount:0,
    tce_remark:'',
    tce_address:'福建省福州市闽侯县烟草专卖局',
    evi_number:0,//数量(条)
    ciga_variety:'',//品种
    barcode:'',//条形码
    ciga_model:'',//规格型号
    ciga_price:0,//单价
    inkjet:'',//
    mer_format:'',
    mer_address:'',
    mer_person:'',
    mer_record:'',
    date_of_record:'',
    date_of_effect:'',
    date_of_issue:'',
    mer_hometown:'',
    mer_id_number:'',
    mer_tel:'',
    business_licence_code:'',
    licence_state:'',
    storage_address:'',
    retail_licence_code:'',
    category:'',
    area_id:0,
    mer_zip_code:0,
    mer_name:'',
    remark:'',
});


//获取案由信息数据用作选项框
interface illegal_data {
    tlc_id:number,
    illegal_behavior:string,
    standard:string,
    penalty_range:string,
    statutory_penalty:string,
    grade:string,
    remark:string,
}
const illegal_Data = ref<illegal_data[]>([]);
const get_legal_clause_opinion = (illegal_behavior:string='',standard:string='' ,grade:string='',tlc_id:number) =>{
    fetchData_legal_clause(illegal_behavior, standard,grade,tlc_id).then(res =>{
        illegal_Data.value = res.data.data;
    })
}
get_legal_clause_opinion();


//视图/


const Advance_notice_Visible=ref(false);                                    //行政处罚事先告知书
const View_administrative_fine_Visible=ref(false);                           //行政罚款收据预览视图
const Return_item_Browse_Visible=ref(false);                          //涉案物品返还清单视图
const Administrative_fine_Visible=ref(false);                                 //行政罚款收据上传视图
const Return_article_list_Visible=ref(false);                                  //涉案物品返还清单视图


const administrative_fine_table=(row:any)=>{
    create_case.case_id=row.case_id;
    img_form_data.case_number=row.case_number;
    Administrative_fine_Visible.value=true;
}

const img_form_data = reactive({
    case_number: '',
    name:'',
    content:'',
    remark:'',
    img:'',
    time:'',
});
const img = [];
const handleChange = (file) =>{
    img.push(file);
}
const handleRemove = (file) =>{
    img.forEach(function (item,index,arr){
        if (item.name == file.name){
            img.splice(index,1)
        }
    })
}

const certern_administrative_fine=()=>{
    if(img_form_data.time.length==0){
        alert("请选择上传时间")
    }else{
        var form = new FormData();
        form.append('format',img[0].raw.type)
        form.append("file",img[0].raw)
        form.append("case_number",img_form_data.case_number)
        form.append("name","行政罚款收据")
        form.append("type","行政罚款收据")
        fetchData_s_mongodb_evidence_Cre(form).then(res=>{
            if (res.data.message === "success"){
                ElMessage.success('行政罚款收据上传完成');
                Administrative_fine_Visible.value = false;
                create_case.tcs_note = "行政罚款收据上传完成"
                fetchData_case_update(create_case.case_id,create_case.tcs_note).then(res=>{
                    if (res.data.message === "success"){
                        //ElMessage.success('状态更新成功');
                        getData();
                    }else {
                        ElMessageBox.confirm('状态更新失败', '提示', {
                            type: 'warning'
                        })
                    }
                })
                fetchData_time_upload(create_case.case_id,img_form_data.time).then(res=>{
                    if (res.data.message === "success"){
                        //ElMessage.success('状态更新成功');
                        getData();
                    }else {
                        ElMessageBox.confirm('状态更新失败', '提示', {
                            type: 'warning'
                        })
                    }
                })
                getData();
            }else {
                ElMessageBox.confirm('状态更新失败', '提示', {
                    type: 'warning'
                })
            }
        })
    }

}

//涉案物品返还清单填写
const return_article_table=(row:any)=>{
    create_case.case_id=row.case_id;
    get_return_item_clause_opinion();
    get_return_item_Data(row.case_id);
    Return_article_list_Visible.value=true;
}

interface Evidence_ciga_data {
    evi_id:number,
    evi_number:number,
    ciga_variety:string,
    ciga_type:string,
    barcode:string,
    ciga_model:string,
    inkjet:string,
    item_id:number,

}
const evidence_ciga_Data= ref<Evidence_ciga_data[]>([]);
const get_return_item_Data=(case_id:number)=>{
    return_item_Views(create_case.case_id).then(res=>{
        evidence_ciga_Data.value=res.data.data;
    })
}
const return_article_data_storage=reactive({
    return_time:'',
    returnee1:'',
    returnee2:'',
    identificate_loss:'',
    evi_id:'',
    return_article:'',
    ciga_number:'',
    identificate_loss_chinese:'',
    staff_license_1:'',
    staff_license_2:'',
    tir_person:'',
})

const return_item_add=()=>{
    return_item_Create(create_case.case_id,return_article_data_storage.evi_id).then(res=>{
        evidence_ciga_Data.value=res.data.data;
        if (res.data.message ==="success"){
            ElMessage.success(`添加成功`);
        }else {
            ElMessageBox.confirm('添加失败', '提示', {
                type: 'warning'
            })
        }
    });
}

const returnDelete=(index:number,row:any)=>{
// 二次确认删除
    ElMessageBox.confirm('确定要删除吗？', '提示', {
        type: 'warning'
    }).then(()=>{
        return_item_clause_delete(row.item_id).then(res=>{
            if (res.data.message === "success"){
                evidence_ciga_Data.value.splice(index, 1);
                ElMessage.success('删除成功');
            }else{
                ElMessageBox.confirm('删除失败', '提示', {
                    type: 'warning'
                })
            }
        })
    })
        .catch(() => {});
}

const certain_case_return=()=>{
    if(return_article_data_storage.return_time.length==0){
        alert("请选择返还时间")
    }else{
        create_case.tcs_note = "行政罚款收据已完成"
        fetchData_case_return_Confirm(
            create_case.case_id,
            return_article_data_storage.return_time,
            return_article_data_storage.identificate_loss,
            return_article_data_storage.returnee1,
            return_article_data_storage.returnee2
        ).then(res=>{
            if (res.data.message === "success"){
                getData()
                fetchData_case_update(create_case.case_id,create_case.tcs_note).then(res=>{
                    if (res.data.message === "success"){
                        ElMessage.success('行政罚款收据已完成');
                        getData();
                        Return_article_list_Visible.value = false;
                    }else {
                        ElMessageBox.confirm('状态更新失败', '提示', {
                            type: 'warning'
                        })
                    }
                })
            }else{
                ElMessageBox.confirm('确认失败', '提示', {
                    type: 'warning'
                })
            }
        })
    }

}



//获取询问人
interface interrogator_data{
    staff_id:number,
    staff_name:string
}
//获取询问者选择框
const interrogator_Data=ref<interrogator_data[]>([]);
const get_interrogator_clause_opinion=(staff_id:number,staff_name:string='')=>{
    fetchData_interrogator_clause(staff_id,staff_name).then(res=>{
        interrogator_Data.value=res.data.data
    })
}
get_interrogator_clause_opinion()


//获取要返还的物品清单
interface return_item_data{
    evi_id:number,
    return_item_name:string,
}
const return_item_Data=ref<return_item_data[]>([]);
const get_return_item_clause_opinion=()=>{
    fetchData_return_item_clause(create_case.case_id).then(res=>{
        return_item_Data.value=res.data.data;
    })
}
get_return_item_clause_opinion();


//获取证据照片数据
const get_evidence_img_data = (case_number:string='')=>{
    fetchData_s_mongodb_evidence_Views(case_number,"行政罚款收据").then(res=>{
        case_img_Data.value = res.data.data
    })
}
//证据图片
interface Case_img_data {
    img:string,
    type:string,
    fill_time:string,
    time_now:string,
}
const case_img_Data = ref<Case_img_data[]>([]);

const return_item_browse=(row:any)=>{
    create_case.case_id=row.case_id;
    get_return_item_Data(create_case.case_id);
    Return_item_Browse_Visible.value=true;
    get_return_item_print_data();
}

const administrative_fine_browse=(row:any)=>{
    create_case.case_id=row.case_id;
    create_case.case_number=row.case_number;
    get_evidence_img_data(create_case.case_number);
    get_administrative_fine_browse_data(create_case.case_id);
    View_administrative_fine_Visible.value = true;
}

const administrative_fine_data_storage=reactive({
    tir_person:'',
    illegal_behavior:'',
    year1:'',
    month1:'',
    day1:'',
    year2:'',
    month2:'',
    day2:'',
    administrative_fine_chinese:'',
    administrative_fine:'',
})

const get_administrative_fine_browse_data=(case_id:number)=>{
    administrative_fine_browse_data(create_case.case_id).then(res=>{
        administrative_fine_data_storage.tir_person=res.data.data.tir_person,
        administrative_fine_data_storage.illegal_behavior=res.data.data.illegal_behavior
        administrative_fine_data_storage.year1=res.data.data.year1
        administrative_fine_data_storage.month1=res.data.data.month1
        administrative_fine_data_storage.day1=res.data.data.day1
        administrative_fine_data_storage.administrative_fine_chinese=res.data.data.administrative_fine_chinese
        administrative_fine_data_storage.administrative_fine=res.data.data.administrative_fine
        administrative_fine_data_storage.year2=res.data.data.year2
        administrative_fine_data_storage.month2=res.data.data.month2
        administrative_fine_data_storage.day2=res.data.data.day2
    })
}


const get_return_item_print_data=()=>{
    return_item_print_data(create_case.case_id).then(res=>{
        return_article_data_storage.ciga_number=res.data.data.ciga_number,
        return_article_data_storage.identificate_loss=res.data.data.identificate_loss,
        return_article_data_storage.identificate_loss_chinese=res.data.data.identificate_loss_chinese,
        return_article_data_storage.returnee1=res.data.data.returnee1,
        return_article_data_storage.returnee2=res.data.data.returnee2,
        return_article_data_storage.staff_license_1=res.data.data.staff_license_1,
        return_article_data_storage.staff_license_2=res.data.data.staff_license_2,
        return_article_data_storage.tir_person=res.data.data.tir_person
    })
}

const return_item_word=()=>{
    return_item_print_data(create_case.case_id).then(res=>{
        export_word_19(
            res.data.data.case_number,
            res.data.data.list,
            res.data.data.ciga_number,
            res.data.data.identificate_loss,
            res.data.data.identificate_loss_chinese,
            res.data.data.returnee1,
            res.data.data.returnee2,
            res.data.data.staff_license_1,
            res.data.data.staff_license_2
        )
    })
}



const query = reactive({
    case_id:0,
    case_source:'',
    case_type:'',
    tcs_note_id:'',
    case_number:'',
    cs_note_id:'',//送达文书状态
    pageIndex: 1,
    pageSize: 10
});
const tableData = ref<TableItem[]>([]);
const tableList = ref<TableItem[]>([]); // 用于存放分页数据的列表
const pageTotal = ref(0);
const name = localStorage.getItem('ms_username');
// 获取表格数据
const getData = (archive_person:string='',case_id:number,case_source:string='',case_type:string='',case_number:string='',tcs_note_id:string='',name:string='') => {
    fetchData_case(archive_person,case_id,case_source,case_type,case_number,tcs_note_id,name).then(res => {
        tableData.value = res.data.data.filter((i: { tcs_note_id: string; }) =>(
            i.tcs_note_id =="无证经营公示已完成" ||
            i.tcs_note_id=="行政处罚决定书已完成"||
            i.tcs_note_id=="行政罚款收据上传完成"||
            i.tcs_note_id=="行政罚款收据已完成"||
            i.tcs_note_id=="结案报告表已完成"||
            i.tcs_note_id=="已完成"
        )  )
      tableList.value = [];
      pageTotal.value = tableData.value.length || 50;
      // 根据页码确定下标位置
      const index: number = query.pageIndex * query.pageSize - query.pageSize;
      for (let i = index; i < index + query.pageSize; i++) {
        // 防止数组下标越界
        if (i <= tableData.value.length - 1) {
          tableList.value.push(tableData.value[i])
        } else {
          // 越界就不再循环
          break;
        }
      }
    });
};
getData('','','','','','',localStorage.getItem('ms_username'));
// 查询操作
const handleSearch = (case_number:string='',tcs_note_id:string='',case_source:string='',case_type:string='') => {
    getData('','',case_source,case_type,case_number,tcs_note_id,name);
};
// 分页导航
const handlePageChange = (val: number) => {

  query.pageIndex = val;
    getData('','','','','','',localStorage.getItem('ms_username'));
};
</script>

<style scoped>
.handle-box {
    margin-bottom: 20px;
}
.handle-box button{
    background-color: #00a854;
}

.handle-select {
    width: 120px;
}

.handle-input {
    width: 300px;
}
.table {
    width: 100%;
    font-size: 14px;
}
.red {
    color: #ff0000;
}

:deep(.avatar){
    width: 100px;
    height: 100px;
}
.blue {
    color: rgba(0, 118, 252, 0.79);
}
.mr10 {
    margin-right: 10px;
}
.table-td-thumb {
    display: block;
    margin: auto;
    width: 500px;
    height: 500px;
}
.dialog-footer button{
    background-color: #00a854;
    color:white;
}


/*#inspect_record{*/
/*  position: relative;*/
/*  left: 0px;*/
/*  top: -20px;*/

/*}*/

/*#filing_report_review{*/
/*  position: relative;*/
/*  left: 0px;*/
/*  top: -22px;*/
/*}*/
</style>
